{extend name="base"/}
{block name="main"}
<article class="cl pd-20">
	<div class="n_tab_line">
		<a href="" class="n_tab_list">客服</a>
		<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px;display: none;" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
		<div class="cl"></div>
	</div>
	<div class="form form-horizontal">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>客服电话：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" autocomplete="off" value="{$info['value']['Mechak']}" placeholder="Mechak" class="input-text" id="Mechak" name="Mechak">
				<p class="error">请输入客服电话</p>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">是否启用：</label>
			<div class="formControls col-xs-8 col-sm-3 skin-minimal">
				<div class="check-box">
					<input type="checkbox" id="is_use" {eq name="info['is_use']" value="1"}checked="checked"{/eq}>
					<label for="is_use">&nbsp;</label>
				</div>
			</div>
		</div>
		<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
			<input class="btn btn-primary radius" onclick="addAdvertAjax()" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
		</div>
		</div>
	</div>
	<input type="hidden" value="{$info['id']}" id="id">
</article>
{/block}
{block name="script"}
<script src="/static/js/ajax_file_upload.js" type="text/javascript"></script>
<script src="/static/js/file_upload.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
});
function addAdvertAjax() {
    var Mechak = $("#Mechak").val();
    var id = $("#id").val();
    if($("#is_use").prop("checked")){
        var is_use = 1;
    }else{
        var is_use = 0;
    }
    if(verify(Mechak)){
        $.ajax({
            type : "post",
            url : "{:url('config/Cse')}",
            data : {
                'id' : id,
                'Mechak' : Mechak,
                'is_use' : is_use,
            },
            success : function(data) {
                if (data["code"] > 0) {
                    layer.msg('添加成功!',{icon:1,time:1000},function () {
                        window.parent.location.href="{:url('config/Cse')}";
                    });
                }else{
                    layer.msg(data['message'],{icon:5,time:1000});
                }
            }
        });
    }
}
function verify(Mechak){
    if(Mechak == ''){
        $("#Mechak").next(".error").show();
        $('#Mechak').focus();
        return false;
    }else{
        $(".error").hide();
    }
    return true;
}
</script>
{/block}